package com.clkj.sunhelp.adapter.list;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.clkj.sunhelp.R;
import com.clkj.sunhelp.bean.YearItem;

import java.util.List;

/**
 * Created by Administrator on 2017/3/29.
 */

public class ListAdapterForReleaseYearChoose extends BaseAdapter {

    List<YearItem> mYearList;
    Context context;
    LayoutInflater layoutInflater;

    public ListAdapterForReleaseYearChoose(List<YearItem> mYearList, Context context) {
        this.mYearList = mYearList;
        this.context = context;
        layoutInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return mYearList.size();
    }

    @Override
    public Object getItem(int position) {
        return mYearList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null)
        {
            convertView = layoutInflater.inflate(R.layout.list_item_tv,null);
            viewHolder = new ViewHolder();
            viewHolder.areaNameTv = (TextView) convertView.findViewById(R.id.tv);
            convertView.setTag(viewHolder);
        }else{
            viewHolder = (ViewHolder) convertView.getTag();
        }

        YearItem yearItem = mYearList.get(position);

        viewHolder.areaNameTv.setText(yearItem.getYearName());
        return convertView;
    }


    static class ViewHolder{
        TextView areaNameTv;
    }

}

